export function getRemainHeight(){
    // calculate window inner height - header height
    const md = document.getElementById('main_header')
    if (md){
        return window.innerHeight - md.clientHeight
    }else{
        return window.innerHeight
    }
}

export function getDomRemainHeight(data:{dom_id?:string,dom?:HTMLElement}) {
    let d:HTMLElement|null = null;
    if (data.dom_id){
        const query = document.getElementById(data.dom_id)
        if (query) d = query
    }
    if(data.dom){
        d = data.dom
    }
    if(d) return window.innerHeight - d.getBoundingClientRect().y
    return 0
  }

export function resizeDom(dom_id:string, bot_padding=0){
    const dom = document.getElementById(dom_id)
    if (dom){
        console.log(('resize'));
        const rHeight = getDomRemainHeight({dom})
        // dom.style.height = `${rHeight}px;`
        console.log(bot_padding);
        
        dom.style.maxHeight =`${rHeight-bot_padding}px `
        console.log(rHeight);
    }
}
export function resizeDomElement(dom:HTMLElement, bot_padding=0){
    if (dom){
        console.log(('resize'));
        const rHeight = getDomRemainHeight({dom})
        // dom.style.height = `${rHeight}px;`
        console.log(bot_padding);
        dom.style.maxHeight =`${rHeight-bot_padding}px `
        console.log(rHeight);
    }
}
